<template>
	<view class="content">
		<view class="into" @click="into">
			跳过{{time}}s
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: 3,
				timer: '',
			}
		},
		onShow() {
			this.timer = setInterval(() => {
				console.log(this.time, 'tiaozhuan.............', this.timer)
				if (this.time == 0) {
					clearInterval(this.timer)
					this.timer = null
				} else {
					this.time--
				}
			}, 1000)
		},
		watch: {
			time(newValue, oldValue) {
				if (newValue == 0) {
					if (this.$store.state.token) {
						uni.switchTab({
							url: '../../tabbars/index/index'
						})
					} else {
						uni.navigateTo({
							url: '../guide/guide'
						})
					}
				}
				}
			},
			methods: {
				into() {
					clearInterval(this.timer)
					this.timer = null
					if (this.$store.state.token) {
						uni.switchTab({
							url: '../../tabbars/index/index'
						})
					} else {
						uni.reLaunch({
							url: '../guide/guide'
						})
					}
				},

			}
		}
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		height: 100vh;
		background-image: url('../../../static/start.png');
		background-size: 100% 100%;
		display: flex;
		justify-content: flex-end;
		padding: 40rpx 40rpx;
		box-sizing: border-box;
	}

	.into {
		width: 160rpx;
		height: 52rpx;
		background: rgba(255, 255, 255, 0.5);
		border-radius: 23rpx;
		line-height: 52rpx;
		text-align: center;
		color: rgba(0, 0, 0, 0.38);
		margin-top: var(--status-bar-height)
	}
</style>
